#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@file_name: attempting_to_run_cpu_bound_code_concurrently.py
@date: 2025-07-28 12:11
@author: Falling Snow
@desc: 尝试并行运行 CPU 密集型代码
"""

import asyncio

from util import async_timed


@async_timed()
async def cpu_bound_work() -> int:
    counter = 0
    for i in range(100_000_000):
        counter += 1
    return counter


@async_timed()
async def main():
    task_one = asyncio.create_task(cpu_bound_work())
    task1_two = asyncio.create_task(cpu_bound_work())
    await task_one
    await task1_two


if __name__ == '__main__':
    asyncio.run(main())
